<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>LiftSimu: /Users/alrik/Documents/workspace/LiftSimu/src/JLevelPanel.java Quellcode</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />

<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>

</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  <td id="projectlogo"><img alt="Logo" src="up.png"/></td>
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">LiftSimu
   
   </div>
   <div id="projectbrief">die Simulation einer Liftanlage</div>
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Erzeugt von Doxygen 1.8.0 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Suchen');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Hauptseite</span></a></li>
      <li><a href="annotated.html"><span>Klassen</span></a></li>
      <li class="current"><a href="files.html"><span>Dateien</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Suchen" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>Auflistung&#160;der&#160;Dateien</span></a></li>
    </ul>
  </div>
</div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>Alle</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Klassen</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Dateien</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Funktionen</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variablen</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle">
<div class="title">/Users/alrik/Documents/workspace/LiftSimu/src/JLevelPanel.java</div>  </div>
</div><!--header-->
<div class="contents">
<a href="_j_level_panel_8java.html">gehe zur Dokumentation dieser Datei</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="keyword">import</span> javax.swing.*;
<a name="l00002"></a>00002 <span class="keyword">import</span> java.awt.*;
<a name="l00003"></a>00003 <span class="keyword">import</span> java.io.ByteArrayOutputStream;
<a name="l00004"></a>00004 <span class="keyword">import</span> java.io.IOException;
<a name="l00005"></a>00005 <span class="keyword">import</span> java.io.InputStream;
<a name="l00006"></a>00006 
<a name="l00007"></a>00007 <span class="keyword">import</span> layout.TableLayout;
<a name="l00008"></a>00008 
<a name="l00027"></a>00027 @SuppressWarnings(<span class="stringliteral">&quot;serial&quot;</span>)
<a name="l00028"></a><a class="code" href="class_j_level_panel.html">00028</a> public class <a class="code" href="class_j_level_panel.html" title="in diesem Panel wird für eine Etage die Ruftasten dargestellt">JLevelPanel</a> extends JPanel{
<a name="l00029"></a><a class="code" href="class_j_level_panel.html#a27b3686276d26f30b6ce798d13fa178a">00029</a>    JButton <a class="code" href="class_j_level_panel.html#a27b3686276d26f30b6ce798d13fa178a">Up</a>;
<a name="l00030"></a><a class="code" href="class_j_level_panel.html#aa5c944996def45c2c3394b9cdd24e821">00030</a>    JButton <a class="code" href="class_j_level_panel.html#aa5c944996def45c2c3394b9cdd24e821">Down</a>;
<a name="l00031"></a>00031    
<a name="l00043"></a><a class="code" href="class_j_level_panel.html#abed68a1146646a14f504a4b93550073a">00043</a>     <span class="keyword">private</span> byte[] <a class="code" href="class_j_level_panel.html#abed68a1146646a14f504a4b93550073a" title="Die Methode die die Bilder streamt.">resourceToByteArray</a>(String resName) <span class="keywordflow">throws</span> IOException { 
<a name="l00044"></a>00044          ByteArrayOutputStream byteStream = <span class="keyword">new</span> ByteArrayOutputStream(); 
<a name="l00045"></a>00045          InputStream           iresStream = <a class="code" href="class_j_level_panel.html" title="in diesem Panel wird für eine Etage die Ruftasten dargestellt">JLevelPanel</a>.class.getResourceAsStream(resName); 
<a name="l00046"></a>00046          <span class="keywordtype">int</span>                   bytesRead = 0; 
<a name="l00047"></a>00047          byte[]                tmp = <span class="keyword">new</span> byte[4096]; 
<a name="l00048"></a>00048 
<a name="l00049"></a>00049          <span class="keywordflow">while</span> ( (bytesRead = iresStream.read(tmp, 0, 4096)) &gt; -1 ) 
<a name="l00050"></a>00050            byteStream.write(tmp, 0, bytesRead); 
<a name="l00051"></a>00051              
<a name="l00052"></a>00052          iresStream.close(); 
<a name="l00053"></a>00053          <span class="comment">// JDocs: &quot;Closing a ByteArrayOutputStream has no effect.&quot; </span>
<a name="l00054"></a>00054 
<a name="l00055"></a>00055          <span class="keywordflow">return</span> byteStream.toByteArray(); 
<a name="l00056"></a>00056        } 
<a name="l00057"></a>00057    
<a name="l00058"></a>00058    
<a name="l00070"></a><a class="code" href="class_j_level_panel.html#a9e83f64936b6591f31e71dfffd943043">00070</a>    <span class="keyword">public</span> <a class="code" href="class_j_level_panel.html" title="in diesem Panel wird für eine Etage die Ruftasten dargestellt">JLevelPanel</a>(<span class="keywordtype">int</span> floorNumber, <span class="keywordtype">int</span> endPoint)
<a name="l00071"></a>00071    {
<a name="l00072"></a>00072       <span class="comment">//* Größe</span>
<a name="l00073"></a>00073       setPreferredSize( <span class="keyword">new</span> Dimension( 150, 80 ) );
<a name="l00074"></a>00074       setMinimumSize(<span class="keyword">new</span> Dimension(150,80));
<a name="l00075"></a>00075       <span class="comment">//Layout</span>
<a name="l00076"></a>00076       <span class="keywordtype">double</span>[][] mlayout = <span class="keyword">new</span> <span class="keywordtype">double</span>[][]{
<a name="l00077"></a>00077               <span class="comment">// X-Achse</span>
<a name="l00078"></a>00078             {0.5, 50,50 ,0.5},
<a name="l00079"></a>00079             { TableLayout.FILL}
<a name="l00080"></a>00080           };
<a name="l00081"></a>00081       setLayout(<span class="keyword">new</span> TableLayout(mlayout));
<a name="l00082"></a>00082       
<a name="l00083"></a>00083       setBorder(BorderFactory.createEmptyBorder(20,10,20,10));
<a name="l00084"></a>00084       <span class="comment">//* Komponenten</span>
<a name="l00085"></a>00085       JPanel switchPanel = <span class="keyword">new</span> JPanel();
<a name="l00086"></a>00086       
<a name="l00087"></a>00087       ImageIcon iconup=null;
<a name="l00088"></a>00088       ImageIcon icondown=null;
<a name="l00089"></a>00089          <span class="keywordflow">try</span> {
<a name="l00090"></a>00090             iconup = <span class="keyword">new</span> ImageIcon( resourceToByteArray(<span class="stringliteral">&quot;images/up.png&quot;</span>));
<a name="l00091"></a>00091             icondown = <span class="keyword">new</span> ImageIcon( resourceToByteArray( <span class="stringliteral">&quot;images/down.png&quot;</span>));
<a name="l00092"></a>00092          } <span class="keywordflow">catch</span> (IOException e) {
<a name="l00093"></a>00093             <span class="comment">// TODO Auto-generated catch block</span>
<a name="l00094"></a>00094             e.printStackTrace();
<a name="l00095"></a>00095          }
<a name="l00096"></a>00096          
<a name="l00097"></a>00097 
<a name="l00098"></a>00098       
<a name="l00099"></a>00099       <span class="keywordflow">if</span>(endPoint &lt;= 0){
<a name="l00100"></a>00100          Up=<span class="keyword">new</span> JButton(iconup);
<a name="l00101"></a>00101          add(Up,<span class="stringliteral">&quot;1,0&quot;</span>);
<a name="l00102"></a>00102       }
<a name="l00103"></a>00103       <span class="keywordflow">if</span>(endPoint &gt;= 0){
<a name="l00104"></a>00104          Down=<span class="keyword">new</span> JButton(icondown);
<a name="l00105"></a>00105          add(Down,<span class="stringliteral">&quot;2,0&quot;</span>);  
<a name="l00106"></a>00106       }
<a name="l00107"></a>00107       
<a name="l00108"></a>00108       switchPanel.setBorder(BorderFactory.createEmptyBorder(0,0,0,10));
<a name="l00109"></a>00109       
<a name="l00110"></a>00110       
<a name="l00111"></a>00111       <span class="comment">//* Hintergrundfarbe</span>
<a name="l00112"></a>00112       <span class="keywordflow">if</span>(floorNumber % 2!=0)
<a name="l00113"></a>00113       {     
<a name="l00114"></a>00114          setBackground(Color.white);
<a name="l00115"></a>00115          switchPanel.setBackground(Color.white);
<a name="l00116"></a>00116       }
<a name="l00117"></a>00117       <span class="keywordflow">else</span>
<a name="l00118"></a>00118       {
<a name="l00119"></a>00119          setBackground(Color.lightGray);  
<a name="l00120"></a>00120          switchPanel.setBackground(Color.lightGray);
<a name="l00121"></a>00121       }
<a name="l00122"></a>00122       
<a name="l00123"></a>00123    }
<a name="l00124"></a>00124 }
</pre></div></div><!-- contents -->


<hr class="footer"/><address class="footer"><small>
Erzeugt am Fre Jul 6 2012 16:05:55 für LiftSimu von &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.0
</small></address>

</body>
</html>
